<?php 
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('FCPATH', str_replace("\\", "/", str_replace(SELF, '', __FILE__)));
error_reporting(E_ALL ^ E_NOTICE);
header('Content-Type:text/html;charset=UTF-8');
require_once(FCPATH.'config.php');
if(!is_referer()){
exit(ERROR);
}
$file_path='gh/ip.txt';
$ip=$_SERVER['REMOTE_ADDR'];
if(is_file($file_path) == true) 
{
$ad = nl2br(file_get_contents($file_path));
$vip=str_replace('<br />','',$ad);
if($vip != "")
{
if(strstr($vip,$ip))
{
$result = array(
		'code'=>405,
		'msg'=>'<pi>sorry，你请求已被外星人拦截！</pi>'
	);
	echo json_encode($result);

exit;
}
}
}

if($_POST["vkey"] == ""){
     $result = array(
		'code'=>403,
		'msg'=>'<pi>'.$data["msg"].'</pi>'
	);
	echo json_encode($result);
exit;
}

$url=authcode(urldecode($_POST["vkey"]),'DECODE',token,0);


if($url == ""){
     $result = array(
		'code'=>403,
		'msg'=>'<pi>'.$data["msg"].'</pi>'
	);
	echo json_encode($result);
exit;
}
if($Cookie_ckflv == "1")
{
if(strstr($url,'.qq.com/'))
{
$Cookie = $Cookieqq;
}
else if(strstr($url,'.youku.com/'))
{
$Cookie = $Cookieyk;
}
if(strstr($url,'.mgtv.com/'))
{
$Cookie = $Cookiemg;
}
else if(strstr($url,'.iqiyi.com/'))
{
$Cookie = $Cookieqy;
}


$url=$keya."/api/?key=".key."&ver=v520.1.18.023"."&url=".$url;
$data = curl($url,$key,$Cookie);
}
else
{
$url=$keya."/api/?key=".key."&ver=v520.1.18.023"."&url=".$url;
$data = curl($url,$key,"");
}

echo $data;

function curl($url,$key,$Cookie) {

$header = array(
  'code: 1.1',
  'key: '.$api_xiao,
  'ip: '.$ip
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIE, $Cookie); 
curl_setopt($curl, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']); 
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($curl);
curl_close($curl);

$data = json_decode($data,true);

if($data["url"] == "")
{
if($data["code"] != "405")
{
$click = "403";
}
else
{
$click = "405";
}
$result = array(
		'code'=>$click,
		'success'=>0,
		'msg'=>'<pi>'.$data["msg"].'</pi>'

	);
	return json_encode($result);
}

if($data["pic"] == "")
{
$pic = img;
}
else
{
$pic = $data["pic"];
}

if(strpos($url,'miguvideo.com')){
    $result = array(
		'code'=>$data["code"],
		'play'=>'ck',
		'url'=>urldecode($data["url"]),
		'img'=>$pic,
		'name'=>'咪咕视频',
		'id'=>uid,
		'msg'=>'<pi>'.$data["msg"].'</pi>'
	);
	return json_encode($result);


} else {
 


$result = array(
		'code'=>$data["code"],
		'play'=>'dp',
		'url'=>urldecode($data["url"]),
		'img'=>$pic,
		'name'=>$data["name"],
		'id'=>uid,
		'msg'=>'<pi>'.$data["msg"].'</pi>'
		
	);
	return json_encode($result);
}
 ;}